package com.lmx.repoDomain.tmodel;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;

/**
 * 老人用餐菜单
 *
 * @author ytche
 * @date 2017年9月4日
 *
 */
@Entity
@Table(name = "tnb_menu")
@JsonApiResource(type = "foodMenu")
public class FoodMenu extends BaseEntity {
	private static final long serialVersionUID = 1L;
	private Set<Food> food;
	private Integer status;// 0未激活1已激活

	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinTable(name = "rel_menu_food", joinColumns = { @JoinColumn(name = "menu_id") }, inverseJoinColumns = { @JoinColumn(name = "food_id") })
	@Fetch(FetchMode.JOIN)
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public Set<Food> getFood() {
		return food;
	}

	public void setFood(Set<Food> food) {
		this.food = food;
	}

	@Column(name = "status")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
}
